package com.sunshine.lnuplus.internet

import android.content.Context
import com.google.gson.Gson
import com.sunshine.lnuplus.model.XiaoAiBean
import com.sunshine.lnuplus.utils.XiaoAiUtils
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import java.io.IOException

/**
 * Created by sunshine on 2020/4/9
 */

object ToXiaoAi {

//    fun toXiaoAi(miId: String, deviceId: String, cookie: String){
//        val url = "https://i.ai.mi.com/course/courseInfos"
//        XiaoAiUtils.lessonToXiaoAiJson(deviceId, miId).forEach {
//            val xiaoAiBean = XiaoAiBean(0, it)
//            println(it)
//            val okHttpClient = OkHttpClient()
//                .newBuilder()
//                .followRedirects(false)
//                .build()
//            val headers = FormBody.Builder()
//                .add("Referer", "https://i.ai.mi.com/h5/precache/ai-schedule/")
//                .add("Cookie", cookie)
//                .build()
//            val requestBody = RequestBody.create("application/json".toMediaTypeOrNull(), Gson().toJson(xiaoAiBean))
//            val request = Request.Builder()
//                .url(url)
//                .post(headers)
//                //.post(requestBody)
//                .build()
//            val call = okHttpClient.newCall(request)
//            call.enqueue(object : Callback {
//                override fun onFailure(call: Call, e: IOException) {
//                    println(e)
//                }
//
//                @Throws(IOException::class)
//                override fun onResponse(call: Call, response: Response) {
//                    println(response.body!!.string())
//                }
//            })
//        }
//    }
}